<?php

namespace app\api\validate;

use think\Validate;
use think\Response;
use think\exception\HttpResponseException;

class BaseValidate extends Validate
{
    public function goCheck($scene = false){
        // 获取请求传递过来的所有参数
        $params = request()->param();
        // 开始验证
        $check = $scene ?
               $this->scene($scene)->check($params):
               $this->check($params);
        if (!$check) {
            
            $result = [
                'code' => 0,
                'msg'  => $this->getError()
            ];
            $response = Response::create($result, 'json', 400);
            throw new HttpResponseException($response);
        }
        return true;
   }
   
    // 是否包含html
    // protected function chekHtml($value,$rule='',$data='',$field='')
    // {
    //      if($value != strip_tags($value)){
    //       return '内容格式违规';
    //      }else{
    //       return true;
    //      }
    // }
}
